<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="thx" uri="/thx-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fun" uri="http://java.sun.com/jsp/jstl/functions"%>
<link rel="stylesheet" type="text/css" media="all" href="${pageContext.request.contextPath}/scripts/lib/bootstrap-daterangepicker/daterangepicker.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/lib/bootstrap-daterangepicker/moment.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/lib/bootstrap-daterangepicker/daterangepicker.js"></script>
<style type="text/css">
     .date-empty-icon {
       	 right: 30px;
       	 cursor: pointer;
     }
     .date-icon {
       	 right: 355px;
       	 cursor: pointer;
     }
</style>

<section class="content-header">
	<h1>
		日志管理<small>系统管理</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
		<li><a href="#">系统管理</a></li>
		<li class="active">日志管理</li>
	</ol>
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box">
				<div class="box-header with-border">
					<div class="row">
						<form class="search-panel" action="sys/log!list.action" name="search-form" result-container=".content-wrapper">
							<input type="text" name="entity.userName" value="${entity.userName}" class="form-control" placeholder="操作人" >
				            <input type="text" id="dateInput" name="dateRange" value="${dateRange}" class="form-control" placeholder="时间区间" style="width:340px; padding-left:28px" readonly="readonly">
	            			<i class="glyphicon glyphicon-remove fa fa-calendar date-empty-icon"></i>
	            			<i class="glyphicon glyphicon-calendar fa fa-calendar date-icon"></i>
							<button type="button" class="btn btn-primary search-btn"  >搜索</button>
						</form>
					</div>
				</div>
				<div class="box-body no-padding">
					<div class="row">
						<div class="col-sm-12">
							<table class="table table-bordered">
								<tr>
									<th>
										<button title="全选"
											class="btn btn-default btn-sm checkbox-toggle"
											data-toggle="tooltip" data-placement="left">
											<i class="fa fa-square-o"></i>
										</button>
									</th>
									<th>操作人</th>
									<th>操作内容</th>
									<th>操作应用</th>
									<th>操作模块</th>
									<th>操作结果</th>
									<th>操作日期</th>
									<th width="9%">操作</th>
								</tr>
								<c:if test="${empty list}">
									<tr>
										<td colspan="8">暂无数据！</td>
									</tr>
								</c:if>
								<c:forEach items='${list }' var="log">
									<tr>
										<td>
											<input type="checkbox" name="delId" value="${log.logId}"/>
										</td>
										<td><thx:user value="${log.userId}" more="true"></thx:user></td>
										<td>${log.action}</td>
										<td>${log.appName}</td>
										<td>${log.module}</td>
										<td>${log.result}</td>
										<td><fmt:formatDate value="${log.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
										<td>
											<button type="button"
													title="详情"
													data-toggle="tooltip"
													data-placement="bottom"
													win-title="详情"
													open-url="sys/log!view.action?id=${log.logId}"
													class="btn btn-default btn-sm btn-open-form">
													<i class="fa fa-sticky-note-o"></i>
											</button>
											<thx:privileged id="sys_log_del">
												<button type="button"
														title="删除"
														data-toggle="tooltip"
														data-placement="bottom"
														do-url="sys/log!delete.action?id=${log.logId}"
														load-url="sys/log!list.action"
														confirm-msg="确定要删除吗？"
														class="btn btn-default btn-sm btn-open-confirm-win">
														<i class="fa fa-trash"></i>
												</button>
											</thx:privileged>
										</td>
									</tr>
								</c:forEach>
							</table>
						</div>
					</div>
				</div>
				<div class="box-footer">
					 <!--分页区-->
					<div class="pagePanel">
			           	 <thx:pages pageNo="page.curPage" total="page.totalPage"  theme="number">
							<s:param name="entity.userName" value="entity.userName"></s:param>
							<s:param name="dateRange" value="dateRange"></s:param>
						 </thx:pages>
					</div>
					 <!--底部操作区-->
					<div class="handlePanel">
						 <thx:privileged id="sys_log_delMulti">
							<a title="批量删除" class="a-btn btn-open-confirm-win btn-get-checkbox-ids" href="javascript:void(0);"
								do-url="sys/log!delMulti.action?delId="
								load-url="sys/log!list.action"
								confirm-msg="确定要删除吗？"
								style="margin-right: 5px">
								<span class="fa fa-trash"></span>
								<span class="text">删除</span>
							</a>
				          </thx:privileged>
					</div>
			    </div>
			</div>
		</div>
	</div>
</section>

<script>
		$(function() {
			list.init();
			page.init();

			$('#dateInput').daterangepicker({
			    "showDropdowns": true,
			    "timePicker": true,
			    "timePicker24Hour": true,
			    "timePickerSeconds": true,
			    "ranges": {
			       '今日': [moment().startOf('day'), moment()],
                   '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                   '最近7日': [moment().subtract('days', 7), moment()],
                   '最近30日': [moment().subtract('days', 30), moment()]
			    },
			    "locale": {
			        "format": "YYYY/MM/DD HH:mm:ss",
			        "separator": " - ",
			        "applyLabel": "应用",
			        "cancelLabel": "取消",
			        "fromLabel": "从",
			        "toLabel": "到",
			        "customRangeLabel": "自定义",
			        "daysOfWeek": ['日', '一', '二', '三', '四', '五', '六'],
			        "monthNames": ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
			        "firstDay": 1
			    },
			    "linkedCalendars": false
			}, function(start, end, label) {
			});

			$(".date-empty-icon").click(function() {
				$('#dateInput').val("");
			});

			var dateRange = '${dateRange}';
			if(dateRange == ''){
				$('#dateInput').val("");
			}
		});
</script>

